package com.shop.admin.controller;

import com.alibaba.fastjson.JSON;
import com.shop.entity.dto.AdminOrders.*;
import com.shop.entity.pojo.OrdersDetail;
import com.shop.admin.service.OrdersDetailService;
import com.shop.admin.service.OrdersService;
import com.shop.utils.common.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/orders")
public class AdminOrdersController {

    @Autowired
    private OrdersService ordersService;
    @Autowired
    private OrdersDetailService ordersDetailService;

//    @GetMapping("/get_new_orders")
//    public Result newOrders(String message){
//        return ordersService.getNewOrders();
//    }

    @PostMapping("/get_orders_list")
    public Result ordersList(@RequestBody AdminOrdersListDto dto){
        return ordersService.getAdminOrdersList(dto);
    }

    @PostMapping("/get_orders_detail")
    public Result<List<OrdersDetail>> ordersDetailList(@RequestBody AdminOrdersGetDetailDto dto){
        return ordersDetailService.getOrdersDetail(dto);
    }

    @PostMapping("/remove_orders")
    public Result removeOrders(@RequestBody AdminOrdersRemoveDto dto){
        return ordersService.delOneOrders(dto);
    }

    @PostMapping("/restore_orders")
    public Result restoreOrders(@RequestBody AdminOrdersRestoreDto dto){
        return ordersService.restoreOrders(dto);
    }

    @PostMapping("/update_orders_state")
    public Result updateOrdersState(@RequestBody AdminOrdersStatUpdateDto dto){
        return ordersService.updateOrdersState(dto);
    }

}
